home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10758 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: druid.borland.com!usenet
  2. From: pete@borland.com (Pete Becker)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: operator % - compiler error
  5. Date: 19 Mar 1996 20:35:45 GMT
  6. Organization: Borland International
  7. Message-ID: <4in5r1$j90@druid.borland.com>
  8. References: <4ihuuh$6ul@hatathli.csulb.edu> <4in0ih$o43@zeus.intellinet.com>
  9. NNTP-Posting-Host: pbecker.borland.com
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=ISO-8859-1
  12. X-Newsreader: WinVN 0.99.5
  13.  
  14. In article <4in0ih$o43@zeus.intellinet.com>, JerryD@prodentec.com says...
  15. >
  16. >davidcho@csulb.edu (David Cho) wrote:
  17. >
  18. >>When I try to compile, I get an erro message for the following line:         
  19.   
  20. >
  21. >
  22. >>x=663608941*y%pow(2,32)  /*I want remainder*/
  23. >
  24. >>But the error message says "illegal use of floating point".  What does 
  25. >>that mean?  Isn't % used a an operator to calcuate the remainder?
  26. >
  27. >In Microsoft and Borland, the pow() function takes two doubles and
  28. >returns a double.  The % operator can't take a double in either
  29. >argument, thus causing the error.  Try casting it like such:
  30. >x=663608941*y%(long)pow(2,32);
  31.  
  32. With Borland C++ 5.0 the result of casting pow(2,32) to a long is 0. I haven't 
  33. tried it with Microsoft, but I would expect the same result. Technically the 
  34. result of this conversion is undefined for any system that uses 32-bit longs, 
  35. since the value cannot be represented in 32 bits.
  36.  
  37.